let s = "  hello world  "
var reverseWords = function(s) {
    let arr = s.split(" ").filter((item)=>{
    return item!==''
})
let n = arr.length
let a = arr[n-1]
   for(let i=1;i<n;i++){
    a=a+" "+arr[n-1-i]
   }
   return a
};
console.log(reverseWords(s));
